package com.bluemsun.naturallanguageprocessing.exceptionHandler;

import com.bluemsun.naturallanguageprocessing.common.ServerResponse;
import com.bluemsun.naturallanguageprocessing.exception.UserNullException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author hucl
 * @describe 用户异常全局处理类
 */
@RestControllerAdvice
public class UserExceptionHandler {
    private static final Logger logger = LoggerFactory.getLogger(UserExceptionHandler.class);
    @ExceptionHandler(UserNullException.class)
    public ServerResponse exception(UserNullException e){
        logger.error(e.getMessage());
        return ServerResponse.createByErrorMessage(e.getMessage());
    }
}
